package com.view.cn.mvprxjava.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.view.cn.mvprxjava.R;
import com.view.cn.mvprxjava.view.PieView;

import java.util.ArrayList;

/**
 * 自定义view
 * Created by Administrator on 2016/9/22 0013.
 */
public class PieViewFragment extends BaseFragment {


	public static final String TAG = PieViewFragment.class.getSimpleName();

	private ArrayList<PieData> mPieDataList = new ArrayList<>();
	private PieView mPieView;

	public static PieViewFragment newInstance() {
		PieViewFragment fragment = new PieViewFragment();
		return fragment;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Nullable
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_pieview, container, false);
		initView(view);
		initData();
		return view;
	}


	private void initView(View view) {
		mPieView = (PieView) view.findViewById(R.id.pieView);
	}

	private void initData() {
		for (int i = 0; i < 5; i++) {
			PieData pieData = new PieData("数据" + i, i);
			mPieDataList.add(pieData);
		}
		mPieView.setPieData(mPieDataList);
	}

	public class PieData {
		//用户关心的数据
		public String name;//名字
		public float value;//数值
		public float percentage;//百分比

		//非用户关心的数据
		public int color = 0;//颜色
		public float angle = 0;//角度

		public PieData(String name, float value) {
			this.name = name;
			this.value = value;
		}
	}

}
